package com.example.arena;



import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LayoutAnimationController;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 
 * @author Dani
 *  Just an animation which leads to the main menu
 */
public class SplashActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);
		//Load the elements for the animation
		TextView titulo = (TextView) findViewById(R.id.titulo);
		ImageView logo = (ImageView) findViewById(R.id.logo);
		  
		//Associating and starting both animations
       Animation animacionFundido = AnimationUtils.loadAnimation(this, R.anim.fade);
       titulo.startAnimation(animacionFundido);
       Animation vueltas = AnimationUtils.loadAnimation(this, R.anim.anim);
       logo.startAnimation(vueltas);
		
       
       logo.setOnClickListener(new View.OnClickListener() {
   	    public void onClick(View view) {
   	    	Intent miIntent = new Intent(SplashActivity.this, MenuActivity.class);
   	    	startActivity(miIntent);
   	    }
   	});

     //If the animation finish before the user clicks on the logo, it will load the menu activity
       animacionFundido.setAnimationListener(new AnimationListener() {
           public void onAnimationEnd(Animation animation) {
               startActivity(new Intent(SplashActivity.this,
            		   MenuActivity.class));
           }
	
       	public void onAnimationStart(Animation arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void onAnimationRepeat(Animation arg0) {
				// TODO Auto-generated method stub
				
			}
       });
           

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.splash, menu);
		return true;
	}

}
